package jdk8.method.reference.demo06.constructor.method.reference;

/**
 * 类的构造器引用
 **/
public class Demo {
    // 参数传递姓名和函数式接口
    public static void printName(String name, PersonBuilder builder) {
        Person p = builder.builderPersonByName(name);
        System.out.println(p.getName());
    }

    public static void main(String[] args) {
        printName("小鸣" ,name -> {
            return new Person(name);
        });

        /*
         方法引用优化
            1. 构造方法new Person(String name)存在
            2. 创建已知对象 new
         */
        printName("小鸣", Person::new);

    }
}
